\rcube_mime_decode

Class for parsing MIME messages

Summary

Methods
Properties
Constants
__construct()
decode()
No public properties found
No constants found
do_decode()
splitBodyHeader()
parseHeaders()
parseHeaderValue()
boundarySplit()
decodeHeader()
structure_part()
$params
N/A
No private methods found
No private properties found
N/A

Properties

$params

$params : array

Class configuration parameters.

Type

array

Methods

__construct()

__construct(array  $params = []) : mixed

Constructor.

Sets up the object, initialize the variables, and splits and stores the header and body of the input.

Parameters

array $params

An array of various parameters that determine various things: include_bodies - Whether to include the body in the returned object. decode_bodies - Whether to decode the bodies of the parts. (Transfer encoding) decode_headers - Whether to decode headers crlf - CRLF type to use (CRLF/LF/CR)

Returns

mixed —

decode()

decode(string  $input, bool  $convert = true) : object|bool

Performs the decoding process.

Parameters

string $input

The input to decode

bool $convert

Convert result to rcube_message_part structure

Returns

object|bool —

Decoded results or False on failure

do_decode()

do_decode(string  $headers, string  $body, string  $default_ctype = 'text/plain') : object|bool

Performs the decoding. Decodes the body string passed to it If it finds certain content-types it will call itself in a recursive fashion

Parameters

string $headers

Header section

string $body

Body section

string $default_ctype

Default content type

Returns

object|bool —

Decoded results or False on error

splitBodyHeader()

splitBodyHeader(string  $input) : array

Given a string containing a header and body section, this function will split them (at the first blank line) and return them.

Parameters

string $input

Input to split apart

Returns

array —

Contains header and body section

parseHeaders()

parseHeaders(string  $input) : array

Parse headers given in $input and return as assoc array.

Parameters

string $input

Headers to parse

Returns

array —

Contains parsed headers

parseHeaderValue()

parseHeaderValue(string  $input) : array

Function to parse a header value, extract first part, and any secondary parts (after ;) This function is not as robust as it could be.

Eg. header comments in the wrong place will probably break it.

Parameters

string $input

Header value to parse

Returns

array —

Contains parsed result

boundarySplit()

boundarySplit(string  $input, string  $boundary) : array

This function splits the input based on the given boundary

Parameters

string $input

Input to parse

string $boundary

Boundary

Returns

array —

Contains array of resulting mime parts

decodeHeader()

decodeHeader(string  $input) : string

Given a header, this function will decode it according to RFC2047.

Probably not exactly conformant, but it does pass all the given examples (in RFC2047).

Parameters

string $input

Input header value to decode

Returns

string —

Decoded header value

structure_part()

structure_part(object  $part, int  $count, string  $parent = '') : object

Recursive method to convert a rcube_mime_decode structure into a rcube_message_part object.

Parameters

object $part

A message part struct

int $count

Part count

string $parent

Parent MIME ID

Returns

object —

rcube_message_part